#include "taskType.h"

taskType::taskType() : itemType (4)
{
}

void taskType::setByItemType( itemType& item )
{
    for (int i=0; i<getDeminition(); i++)
        setField(i, item.getField(i));
}

void taskType::loadInputFromFile(const QString &fileName)
{
    QFile inputFile(fileName);

    inputFile.open( QFile::ReadOnly );

    QTextStream in;
    in.setDevice( &inputFile );

    int n, m;
    in >> m >> n;
    input.resize( m );
    for (int i=0; i<m; i++){
        input[i].resize(n);
        for (int j=0; j<n; j++)
            in >> input[i][j];
    }

    inputFile.close();
}

void taskType::loadOutputFromFile(const QString &fileName)
{
    QFile outputFile(fileName);

    outputFile.open( QFile::ReadOnly );

    QTextStream in;
    in.setDevice( &outputFile );

    int n, m;
    in >> m >> n;
    output.resize( m );
    for (int i=0; i<m; i++){
        output[i].resize(n);
        for (int j=0; j<n; j++)
            in >> output[i][j];
    }

    outputFile.close();
}
